﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace PrattParsing
{
    [DebuggerNonUserCode]
    public abstract class InfixOperatorParselet<E> : InfixParselet<E>
    {
        protected int prec;
        protected int callprec;

        public InfixOperatorParselet(int prec, bool assoc)
        {
            this.prec = prec;
            this.callprec = this.prec;
            if (assoc == PrattParser<object>.ASSOC_RIGHT)
                this.callprec--;
        }

        public abstract E parse(PrattParser<E> parser, E left, Token token);

        public int precedence()
        {
            return prec;
        }
    }
}
